<!--
    @name 索赔结算查询 主页面
    @author haoyang.ding
    @date 2021-2-24
-->
<template>
  <section>
    <OneTableTemplate
      ref="multipleTable"
      :dynamic-components="formInputs"
      :dynamic-buttons="formButtons"
      :dynamic-table-cols="tableHeader"
      :dynamic-is-show-select="false"
      :dynamic-form-fields="formField"
      :dynamic-api-config="dynamicApiConfigs"
      :dynamic-api-style="'restful'"
    />
  </section>
</template>

<script>
import OneTableTemplate from '@/components/templates/oneTable'
import { oneTableWithViewTemplateMixins } from '@/components/mixins/oneTableWithViewTemplateMixins'
import { orgApis } from '@/api/apiClaimMangemet'
import { exportExcel } from '@/utils/getTimeString.js'
export default {
  name: 'ClaimSettlementSearch',
  components: {
    OneTableTemplate
  },
  mixins: [oneTableWithViewTemplateMixins],
  data() {
    return {
      editRowData: {},
      dynamicApiConfigs: orgApis.findClaimSettleAccounts,
      formInputs: [
        {
          compKey: 'key0',
          labelName: '结算日期：',
          codeField: 'balanceStartTime,balanceEndTime',
          isMul: false,
          component: () => import('@/components/org/datePicker/andtDatePicker'),
          type: 'YYYY-MM-DD',
          format: 'yyyy-MM-dd',
          isMust: true
        },
        {
          compKey: 'key1',
          labelName: '结算单号：',
          codeField: 'repairBalanceCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true
        },
        {
          compKey: 'key2',
          labelName: '门店编码：',
          codeField: 'dlrCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
          type: 'inputText',
          isMust: true
        }
      ],
      formButtons: [
        {
          compKey: 'btnKey0',
          type: 'primary',
          size: 'small',
          clickEvent: () => this.queryTable(1),
          text: '查询', // 查询
          name: 'search', // 按钮图标样式
          position: 'right'
        },
        {
          compKey: 'btnKey1',
          size: 'small',
          clickEvent: () => this.export(),
          text: this.$t('sys.button.export'), // 导出
          name: 'export', // 按钮图标样式
          position: 'right'
        },
        {
          compKey: 'btnKey2',
          size: 'small',
          text: this.$t('sys.button.reset'), // 重置
          name: 'reset', // 按钮图标样式
          clickEvent: () => this.reset(),
          position: 'right'
        }
      ],
      tableHeader: [
        {
          prop: 'controlBtn',
          label: '操作', // 操作
          codeField: 'orgName',
          width: null,
          align: 'center',
          isComponent: true,
          comps: [
            {
              compKey: 'propKey0',
              align: 'center',
              labelName: '查看',
              codeField: 'orgName',
              clickEvent: (index) => { this.edit(index) },
              component: () =>
                import('@/components/org/linkButton')
            }
          ]
        },
        {
          label: '门店编码',
          prop: 'dlrCode'
        },
        {
          label: '门店名称',
          prop: 'dlrFullName'
        },
        {
          label: '结算批次',
          prop: 'balanceMonth'
        },
        {
          label: '结算单号',
          prop: 'repairBalanceCode'
        },
        {
          label: '结算日期',
          prop: 'balanceDate'
        },
        {
          label: '工时费',
          prop: 'wiAmount'
        },
        {
          label: '备件费',
          prop: 'partAmount'
        },
        {
          label: '其他费用',
          prop: 'otherAmount'
        },
        {
          label: '外出救援费',
          prop: 'shipAmount'
        },
        {
          label: '意外补偿费',
          prop: 'compAmount'
        },
        {
          label: '索赔金额',
          prop: 'amountIncludeOldfee'
        },
        {
          label: '倒扣金额',
          prop: 'reverseAmount'
        },
        {
          label: '总金额',
          prop: 'totalAmount'
        }
      ],
      formField: {
        balanceStartTime: '',
        balanceEndTime: '',
        repairBalanceCode: '',
        dlrCode: ''
      }
    }
  },
  mounted() {
    this.queryTable(1)
  },
  methods: {
    export() {
      exportExcel(this.formField, orgApis.importClaimSettleAccounts.APIUrl, orgApis.importClaimSettleAccounts.ServiceCode, '索赔结算查询')
    },
    // 编辑获取数据
    edit(index) {
      this.editRowData = this.$utils.deepCopy(this.$refs['multipleTable'].list[index])
      this.$router.push({ name: 'claimSettlementDetail', params: this.editRowData })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
